﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BMC.ARSystem;
using System.Reflection;

namespace Wicresoft.EKA.NRemedy.Test
{
    [TestClass]
    public class ARServer_Test
    {
        [TestMethod]
        public void TestMethod1()
        {

            //Server server = new Server();
            //server.Login("vsjojo", "Demo", "asb#1234");
            //FieldValueList fvl = server.GetEntry("ASB_CMDB_Email", "000000000006322");

            //DateValue dv = new DateValue(DateTime.Now);
            //int a = dv.JulianDate;
            
            //ModelBinder<MockModel7> binder = new ModelBinder<MockModel7>();
            //MockModel7 o = binder.Bind(fvl);
            //o.Assigned_To = "pak";
            //var f = binder.UnBindForUpdate(o);

            

            Server server = new Server();
            server.Login("10.188.238.23", "Demo", "asb#1234");
            server.Logout();

        }

        private class MockModel7 : ARBaseForm
        {

            public enum EnumProperty_Enum
            {
                aa,
                bb
            }



            [ARField(DatabaseID = 536870913, DataType = ARType.DiaryField, BinderAccess = ModelBinderAccessLevel.OnlyUnBind)]
            public string DiaryPropertySet { get; set; }

            [ARField(DatabaseID = 536870913, DataType = ARType.DiaryField, BinderAccess = ModelBinderAccessLevel.OnlyBind)]
            public DiaryList DiaryPropertyGet { get; private set; }

            [ARField(DatabaseID = 536870921, DataType = ARType.SelectionField)]
            public EnumProperty_Enum EnumProperty { get; set; }

            [ARField(DatabaseID = 536870914, DataType = ARType.DateTimeField)]
            public DateTime DateTimeProperty { get; set; }

            [ARField(DatabaseID = 536870917, DataType = ARType.CurrencyField)]
            public CurrencyValue CurrencyProperty { get; set; }

            [ARField(DatabaseID = 536870915, DataType = ARType.DateOnlyField)]
            public DateValue DateOnlyProperty { get; set; }

            [ARField(DatabaseID = 536870916, DataType = ARType.TimeOnlyField)]
            public TimeOfDayValue TimeOnlyProperty { get; set; }

            public enum Status_Enum
            {
                New,
                Assigned,
                Fixed,
                Rejected,
                Closed
            }

            private string _Request_ID;
            private string _Submitter;
            private DateTime _Create_Date;
            private string _Assigned_To;
            private string _Last_Modifed_By;
            private DateTime _Modifed_Date;
            private Status_Enum _Status;
            private string _Short_Description;

            [AREntryKey]
            [ARField(DatabaseID = 1, DatabaseName = "Request ID", DataType = ARType.CharacterField, BinderAccess = ModelBinderAccessLevel.OnlyBind)]
            public string Request_ID
            {
                get
                {
                    return _Request_ID;
                }
                protected set
                {
                    _Request_ID = value;
                    OnPropertyChanged("Request_ID");
                }
            }

            [ARField(DatabaseID = 2, DatabaseName = "Submitter", DataType = ARType.CharacterField)]
            public string Submitter
            {
                get
                {
                    return _Submitter;
                }
                set
                {
                    _Submitter = value;
                    OnPropertyChanged("Submitter");
                }
            }

            [ARField(DatabaseID = 3, DatabaseName = "Create Date", DataType = ARType.DateTimeField, BinderAccess = ModelBinderAccessLevel.OnlyBind)]
            public DateTime Create_Date
            {
                get
                {
                    return _Create_Date;
                }
                protected set
                {
                    _Create_Date = value;
                    OnPropertyChanged("Create_Date");
                }
            }

            [ARField(DatabaseID = 4, DatabaseName = "Assigned To", DataType = ARType.CharacterField)]
            public string Assigned_To
            {
                get
                {
                    return _Assigned_To;
                }
                set
                {
                    _Assigned_To = value;
                    OnPropertyChanged("Assigned_To");
                }
            }

            [ARField(DatabaseID = 5, DatabaseName = "Last Modified By", DataType = ARType.CharacterField, BinderAccess = ModelBinderAccessLevel.OnlyBind)]
            public string Last_Modifed_By
            {
                get
                {
                    return _Last_Modifed_By;
                }
                protected set
                {
                    _Last_Modifed_By = value;
                    OnPropertyChanged("Last_Modifed_By");
                }
            }

            [ARField(DatabaseID = 6, DatabaseName = "Modified Date", DataType = ARType.DateTimeField, BinderAccess = ModelBinderAccessLevel.OnlyBind)]
            public DateTime Modifed_Date
            {
                get
                {
                    return _Modifed_Date;
                }
                protected set
                {
                    _Modifed_Date = value;
                    OnPropertyChanged("Modifed_Date");
                }
            }

            [ARField(DatabaseID = 7, DatabaseName = "Status", DataType = ARType.SelectionField)]
            public Status_Enum Status
            {
                get
                {
                    return _Status;
                }
                set
                {
                    _Status = value;
                    OnPropertyChanged("Status");
                }
            }

            [ARField(DatabaseID = 8, DatabaseName = "Short Description", DataType = ARType.CharacterField)]
            public string Short_Description
            {
                get
                {
                    return _Short_Description;
                }
                set
                {
                    _Short_Description = value;
                    OnPropertyChanged("Short_Description");
                }
            }

        }
    }
}
